package com.atguigu.gmall.search.rpc;


import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.search.entity.Goods;
import com.atguigu.gmall.search.service.SearchService;
import com.atguigu.gmall.search.vo.SearchParamVo;
import com.atguigu.gmall.search.vo.SearchRespVo;
import com.baomidou.mybatisplus.extension.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/inner/rpc/search")
public class SearchRpcController {
    @Autowired
    SearchService searchService;
    @GetMapping("/hotscore/update/{skuId}/{score}")
    public Result updateHotScore(@PathVariable("skuId")Long skuId,
                                 @PathVariable("score")Long score){
        searchService.updateHotScore(skuId,score);
        return Result.ok();
    }
    @GetMapping("/goods/delete/{skuId}")
    public Result deleteGoods(@PathVariable("skuId")Long skuId){
        searchService.deleteGoods(skuId);
        return Result.ok();
    }
    @PostMapping("/goods/save")
    public Result saveGoods(@RequestBody Goods goods){
        searchService.saveGoods(goods);
        return Result.ok();
    }
    @PostMapping("/goods")
    public Result<SearchRespVo> searchGoods(@RequestBody SearchParamVo vo){
        //处理检索
        SearchRespVo resp = searchService.search(vo);
        return Result.ok(resp);
    }
}
